********************************
*** Dataset replication file ***
********************************

*****************************************
*** Insert path file and load dataset ***
*****************************************

import excel "/Users/PathFile/LA turnover.xlsx", sheet("List1") firstrow clear

**************************
*** Summary statistics ***
**************************

tabstat TurnoverPct TermLengthDays TermLimits StaggeredElection Seats SeatChangePct Bicameralism, stat(mean sd min max)

**************************
*** Correlation matrix ***
**************************

correlate TurnoverPct TermLengthDays TermLimits Seats SeatChangePct Bicameralism StaggeredElection

*******************************************************************
*** Running hausman test to decide fixed effects vs mixed model ***
*******************************************************************

xtreg TurnoverPct TermLimits TermLengthDays StaggeredElection Bicameralism Seats SeatChangePct, fe
estimates store fe_model

xtreg TurnoverPct TermLimits TermLengthDays StaggeredElection Bicameralism Seats SeatChangePct, re
estimates store re_model

hausman fe_model re_model

************************************************************************************
*** Two-level hierarchical regression models using CountryID as level 2 variable ***
************************************************************************************

********************************************************
*** Model 1 - controls-only model for lower chambers ***
********************************************************

mixed TurnoverPct Seats SeatChangePct Bicameralism || CountryID:  if LowerorOnlyChamber == 1
estat ic

***********************************************
*** Model 2 - full model for lower chambers ***
***********************************************

mixed TurnoverPct TermLengthDays TermLimits Seats SeatChangePct Bicameralism || CountryID: if LowerorOnlyChamber == 1
estat ic

******************************************************
*** Model 3 - controls-only model for all chambers ***
******************************************************

mixed TurnoverPct Seats SeatChangePct Bicameralism || CountryID:
estat ic

*********************************************
*** Model 4 - full model for all chambers ***
*********************************************

mixed TurnoverPct TermLengthDays TermLimits StaggeredElection Seats SeatChangePct Bicameralism || CountryID: 
estat ic
